#ifndef __RED_FUNCTION_OBJECT_H__
#define __RED_FUNCTION_OBJECT_H__

#include "redobject.h"

typedef struct _RedFunctionObject
{
	RedObject_HEAD

	int			 fn_args;
	RedObject	*fn_code;
	RedObject	*fn_locals;
	RedObject	*fn_closure;
} RedFunctionObject;

RED_EXPORT extern RedTypeObject RedType_Function;

#define RedFunction_Exact(o)		((o)->ob_type == &RedType_Function)

#define RedFunction_Args(o)			(((RedFunctionObject *)(o))->fn_args)
#define RedFunction_Code(o)			(((RedFunctionObject *)(o))->fn_code)
#define RedFunction_Frame(o)		(((RedFunctionObject *)(o))->fn_frame)
#define RedFunction_Locals(o)		(((RedFunctionObject *)(o))->fn_locals)
#define RedFunction_Closure(o)		(((RedFunctionObject *)(o))->fn_closure)

RED_EXPORT RedObject *RedFunction_Invoke(RedObject *self, RedObject *args);
RED_EXPORT RedObject *RedFunction_WrapCode(RedObject *code, RedObject *frame, int args);

#endif /* __RED_FUNCTION_OBJECT_H__ */
